Skip to content

Upgrade VM, crypto, and rand dependencies#3146

Open
huitseeker wants to merge 14 commits into
nextfrom
issue-3064-dependency-upgrade
Open

Upgrade VM, crypto, and rand dependencies#3146
huitseeker wants to merge 14 commits into
nextfrom
issue-3064-dependency-upgrade

Conversation

@huitseeker

@huitseeker huitseeker commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

This updates Miden VM to v0.24, Miden Crypto to v0.27, and rand to v0.10.

The VM upgrade moved package debug info out of MastForest. This PR keeps that debug info attached through scripts, account code, and MAST forest stores by carrying PackageDebugInfoin LoadedMastForest.

This also updates MASM imports and build helpers for the new assembly package API.

Closes #3064

@huitseeker huitseeker marked this pull request as ready for review June 25, 2026 19:57
@huitseeker huitseeker marked this pull request as draft June 25, 2026 19:58
@huitseeker huitseeker marked this pull request as ready for review June 25, 2026 21:01
@@ -1 +1,4 @@
#![cfg_attr(not(feature = "concurrent"), no_std)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to run benchmarks for no_std or why is this needed? I assume this has something to do with all dependencies being made optional as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is Cargo feature unification. The transaction benchmark uses the concurrent proving path. Since 0xMiden/crypto#1073, miden-lifted-stark/concurrent is part of the default crypto stack. In crypto 0.27, miden-crypto/concurrent enables std. On the protocol side, miden-tx/concurrent and miden-processor/concurrent also require std.

That works for the benchmark, but it must not leak into cargo build --no-default-features --target wasm32-unknown-unknown --workspace --lib. So the feature gate keeps normal benchmark builds as the default through default = ["concurrent"], while the no-default library build does not enable the std only benchmark stack.

/cc @WiktorStarczewski @Nashtare

Comment thread crates/miden-agglayer/asm/agglayer/common/asset_conversion.masm

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like a large part of the changes are related to packages and the way we assemble MASM. Does this not result in many conflicts with #2896? That workstream currently has 4 open PRs. So it seems it would make sense to do this migration after that issue was resolved, wdyt?

@huitseeker huitseeker Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this PR is already doing part of issue #2896. The VM 0.24 upgrade removes the old shape of several Library and Program APIs, so this PR has to move some code to Package and MastForest. That is visible in account component code, note scripts, transaction scripts, and the build scripts.

The part this PR does not do is the project file migration. It adds no miden-project.toml files, and it does not move protocol or standards assembly to the declarative project layout from #3094 and #3107.

I think this leaves us with an ordering choice. If we want the dependency upgrade now, this PR can land first and the project file PRs can rebase over it. If we want less churn in the package migration work, this PR can wait and I can rebase it after #3094 and #3107.

/cc @TomasArrachea @bitwalker

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would merge this after #3094 and #3107, and then do another PR after this one that cleans up the parts of #3094/#3107 that are sort of hacky workarounds for the v0.23 APIs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking through this PR, I think I agree with @bitwalker that it would be better to mere #3094 and #3107 first.

This could work well with timing as I think @huitseeker you are out tomorrow (Wednesday).

@partylikeits1983 partylikeits1983 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Really like the new import syntax. There are still many places where the imports can be consolidated. I opened an issue in the VM for adding unused import checking. I think the new import syntax makes it easier to have unused imports.

For the most part looks good so far, I didn't get through everything just yet, will re-review in 24-48h, or feel free to re-request my review if you address things sooner.

@@ -1,4 +1,4 @@
use agglayer::bridge::bridge_in -> bridge
use agglayer::bridge::bridge_in as bridge

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Comment on lines +20 to +23
pub use {
FUNGIBLE_ASSET_MAX_AMOUNT,
ASSET_SIZE,
ASSET_VALUE_MEMORY_OFFSET,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very clean!

Comment thread crates/miden-protocol/asm/kernels/transaction/lib/fungible_asset.masm Outdated
Comment thread crates/miden-protocol/asm/kernels/transaction/lib/link_map.masm Outdated
Comment thread crates/miden-protocol/asm/protocol/input_note.masm Outdated
Comment thread crates/miden-protocol/asm/kernels/transaction/lib/prologue.masm Outdated
Comment on lines +3 to +23
use {
ACCOUNT_GET_ID_OFFSET,
ACCOUNT_GET_NONCE_OFFSET,
ACCOUNT_GET_INITIAL_COMMITMENT_OFFSET,
ACCOUNT_COMPUTE_COMMITMENT_OFFSET,
ACCOUNT_GET_CODE_COMMITMENT_OFFSET,
ACCOUNT_GET_INITIAL_STORAGE_COMMITMENT_OFFSET,
ACCOUNT_COMPUTE_STORAGE_COMMITMENT_OFFSET,
ACCOUNT_GET_INITIAL_VAULT_ROOT_OFFSET,
ACCOUNT_GET_VAULT_ROOT_OFFSET,
ACCOUNT_GET_ITEM_OFFSET,
ACCOUNT_HAS_STORAGE_SLOT_OFFSET,
ACCOUNT_GET_INITIAL_ITEM_OFFSET,
ACCOUNT_GET_MAP_ITEM_OFFSET,
ACCOUNT_GET_INITIAL_MAP_ITEM_OFFSET,
ACCOUNT_GET_ASSET_OFFSET,
ACCOUNT_GET_INITIAL_ASSET_OFFSET,
ACCOUNT_GET_NUM_PROCEDURES_OFFSET,
ACCOUNT_GET_PROCEDURE_ROOT_OFFSET,
ACCOUNT_HAS_PROCEDURE_OFFSET,
} from miden::protocol::kernel_proc_offsets

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When experimenting with this branch locally, I noticed its easy to add imports with this new import syntax, and not actually use the imported procedure or const. I opened an issue in the VM to discuss.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that is a bug if those aren't being used anywhere - we do have unused import checking implemented, but it may be buggy still.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record the imports being commented on in this comment are used.

Comment thread crates/miden-protocol/asm/protocol/active_note.masm Outdated
Comment thread crates/miden-protocol/asm/protocol/active_note.masm Outdated
@huitseeker huitseeker force-pushed the issue-3064-dependency-upgrade branch 2 times, most recently from a2502cf to b2a6275 Compare June 30, 2026 14:18

@bitwalker bitwalker left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only looked over the assembly-related bits, but looks good to me, aside from a couple notes.

Comment thread crates/miden-standards/build.rs Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this whole file gets way simpler once #3094 gets merged - all we have to do is instantiate the project assembler with a package registry that is seeded with miden-core-lib, and request the various target artifacts we want. I'd suggest we rebase this on top of #3094 once that lands

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are the changes here correct? It seems like a bunch of constants are re-defined here now.

I think this will likely need to be rebased after #3094 shifted around a lot of these imports, but the re-definition of constants seems a separate issue so just wanted to flag that

Comment on lines +34 to +45
# The number of field elements in an asset.
const ASSET_SIZE=8

# The size of the memory segment allocated to each note.
const NOTE_MEM_SIZE=1024

# The pointer at which the output vault root starts.
const OUTPUT_VAULT_ROOT_PTR=8

# The offset of the output note section.
const OUTPUT_NOTE_SECTION_OFFSET=16777216

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems that constants have been re-defined across more than just one file

Comment on lines 128 to 129
self.mast_store.insert(TransactionKernel::library().mast_forest().clone());
self.mast_store.insert(program.mast_forest().clone());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, this used to load the debug info in the previous VM versions, and will now fall back to LoadedMastForest::new(...) which no longer contains debug info

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and similarly in other users of TransactionMastStore::insert

Comment on lines +64 to +67
/// Registers all procedures of the provided [Package] with this store.
fn insert_package(&self, package: &Package) {
self.insert_loaded(loaded_mast_forest_from_package(package));
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key function here seems to loaded_mast_forest_from_package which adds the debug info.
It might be worth marking this explicitly in this fn's docs

Comment on lines 59 to +62
/// Registers all procedures of the provided [MastForest] with this store.
pub fn insert(&self, mast_forest: Arc<MastForest>) {
self.insert_loaded(LoadedMastForest::new(mast_forest));
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similarly here (and IIUC) this fn will NOT add debug info, whereas previously it would have by default, because the debug info lived on the MastForest object

Comment on lines 176 to 179
#[must_use]
pub fn with_debug_mode(mut self) -> Self {
self.exec_options = self.exec_options.with_debugging(true);
pub fn with_debug_mode(self) -> Self {
self
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this dead code now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade crypto (0.26) and miden-vm (0.24) dependencies

6 participants